#include "Stair.h"
#include "Resource.h"

Stair::Stair(LPDIRECT3DDEVICE9 d3ddv,  LPDIRECT3DSURFACE9 backBuffer, LPD3DXSPRITE spriteHandler, float x, float y, int ID, int Object_State, int Direction) : Object(x, y)
{
	this->setIDObjType(ID);

	p_sprite = new Sprite(spriteHandler, ResourceMng::GetInst(d3ddv, backBuffer)->GetTexture(ResourceMng::GetInst(d3ddv, backBuffer)->getMapTexture()[11]->getFileName()), 0, 0);

	width = p_sprite->getTexture()->getWidth();
	height = p_sprite->getTexture()->getHeight();

	pos_x = x;
	pos_y = y;

	veloc_x = 0;
	veloc_y = 0;
	this->obj_state = Object_State;

	this->direction = Direction;
	if (direction == 1)			//trai
	{
		p_sprite->setFrame(0,1);
		p_sprite->setIndex(0);
	}
	else						//phai
	{
		p_sprite->setFrame(1,2);
		p_sprite->setIndex(1);
	}
}

Stair::~Stair()
{
	if (p_sprite)
	{
		delete p_sprite;
	}
}

void Stair::update(list<Object*>* obj_list, DxInput* input, float TPF)
{
	Object::update(obj_list, input, TPF);
}

void Stair::render(int cameraX, int cameraY)
{
	if (this->getIDObjType() != 230)
	{
		//p_sprite->render(pos_x, pos_y, cameraX, cameraY);
	}
	//p_sprite->render(pos_x, pos_y, cameraX, cameraY);
}

OBJECT_TYPE Stair::getObjectType()
{
	return OBJECT_STAIR;
}